﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;

using System.Text;
using System.Web.UI.HtmlControls;
using Module.Core.Common;
using Module.Core.Utilities;

namespace Module.Core.Utilities
{
   public class UtilitiesFunctions
   {
       private static string extApp = "";
       public static string ExtApp()
       {
           if(extApp.Equals(""))
           {
               extApp = ConfigurationSettings.AppSettings["extApp"].ToString();
           }
           return extApp;
       }

       private static string urlConfirm = "";
       public static string GetUrlConfirm()
       {
           if(urlConfirm.Equals(""))
           {
               urlConfirm = ConfigurationSettings.AppSettings["linkConfirmMobile"].ToString();
           }
           return urlConfirm;
       }
       private static string linkEncrypt = "";
       public static string GetlinkEncrypt()
       {
           if (linkEncrypt.Equals(""))
           {
               linkEncrypt = ConfigurationSettings.AppSettings["linkEncrypt"].ToString();
           }
           return linkEncrypt;
       }

       private static string linkDecrypt = "";
       public static string GetlinkDecrypt()
       {
           if (linkDecrypt.Equals(""))
           {
               linkDecrypt = ConfigurationSettings.AppSettings["linkDecrypt"].ToString();
           }
           return linkDecrypt;
       }

       private static string urlMsisdn = "";
       public static string GetUrlMsisdn()
       {
           if (urlMsisdn.Equals(""))
           {
               urlMsisdn = ConfigurationSettings.AppSettings["linkMsisdn"].ToString();
           }
           return urlMsisdn;
       }

       public static string GetUrl(int lang, string folderSub, string fileXml)
       {
           if (folderSub == "")
               return System.Web.HttpContext.Current.Server.MapPath(Const.folderRoot + "/" + lang + "/" + fileXml + ".xml");
           else
               return System.Web.HttpContext.Current.Server.MapPath(Const.folderRoot + "/" + folderSub + "/" + lang + "/" + fileXml + ".xml");
       }
       public static string GetUrlWap(int lang, string folderSub, string fileXml)
       {
           if (folderSub == "")
               return ConfigurationSettings.AppSettings["domainNameMobilink"].ToString() + "/" + Const.folderRoot + "/" + lang + "/" + fileXml + ".xml";
           else
               return ConfigurationSettings.AppSettings["domainNameMobilink"].ToString() + "/"+Const.folderRoot + "/" + folderSub + "/" + lang + "/" + fileXml + ".xml";
       }
       public static string GetUrlDetails(int lang, string urlFileXml)
       {
           return
               System.Web.HttpContext.Current.Server.MapPath(Const.folderRoot + "/" + Const.folderCmsContent + "/" + lang + "/" + urlFileXml + ".xml");
       }

       public static HtmlAnchor UrlMenu(DataRowView dv, HtmlAnchor ATitle, int Lang)
       {
           if (dv["StatusClick"].ToString().Trim() == "#")
               ATitle.HRef = "/#";
           else if (dv["ZoneUrl"].ToString().Trim().IndexOf(".") >= 0)
               ATitle.HRef = dv["ZoneUrl"].ToString() + ExtApp();
           else
               ATitle.HRef = "/" + dv["TrangHienThi"] + ExtApp();
           return ATitle;
       }       
    }
}
